home *** CD-ROM | disk | FTP | other *** search
/ Resource Library: Multimedia / Resource Library: Multimedia.iso / maestro / source / videoedt / videdtdt.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-15  |  25.8 KB  |  963 lines

  1. /*
  2.  * Copyright (c) 1990, 1991 Stanford University
  3.  *
  4.  * Permission to use, copy, modify, and distribute this software and 
  5.  * its documentation for any purpose is hereby granted without fee, provided
  6.  * that (i) the above copyright notices and this permission notice appear in
  7.  * all copies of the software and related documentation, and (ii) the name
  8.  * Stanford may not be used in any advertising or publicity relating to
  9.  * the software without the specific, prior written permission of
  10.  * Stanford.
  11.  * 
  12.  * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 
  13.  * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
  14.  * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
  15.  *
  16.  * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
  17.  * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES
  18.  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT
  19.  * ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY,
  20.  * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  21.  * SOFTWARE.
  22.  */
  23.  
  24. /* $Header: /Source/Media/collab/VideoEdit/RCS/VideoEditEdit.c,v 0.31 92/05/13 00:17:32 drapeau Exp Locker: drapeau $ */
  25. /* $Log:    VideoEditEdit.c,v $
  26.  * Revision 0.31  92/05/13  00:17:32  drapeau
  27.  * Extensive changes, mostly cosmetic, to the code:
  28.  * * Cosmetic changes (mostly formatting) to conform to coding standards.
  29.  * * Added the function UpdateHeader() to more cleanly report the
  30.  *   current modification status of the current document.  Modified
  31.  *   several other functions to call this function.
  32.  * * Modified several functions to correctly update status of current
  33.  *   document (whether one is opened, and whether one has been
  34.  *   modified).
  35.  * 
  36.  * Revision 0.30  92/05/12  19:10:20  drapeau
  37.  * Made several modifications to implement changes in the interface.
  38.  * All of these changes are to implement the new "Document" menu
  39.  * on the Edit panel:
  40.  * 
  41.  * * Added FileSaveAs(), EditCloseWindow(), EditCloseFile() functions
  42.  *   to correspond with "Save As", "Close Window", and "Close File"
  43.  *   menu items.
  44.  * * Re-formatted code to conform with coding standards.
  45.  * * Other slight changes to existing FileSave() function to reflect
  46.  *   that it is now a callback of a menu item, not a button.
  47.  * 
  48.  * Revision 0.29  92/01/07  14:09:23  drapeau
  49.  * Modified OpenHandler() to fix an error in reading files.  The error
  50.  * occurred on a boundary condition: if an edit had a label of exactly
  51.  * the maximum length (currently 22 characters), the function would
  52.  * omit the NULL character at the end of the string, which would cause
  53.  * subsequent edits to be incorrectly read.
  54.  * Also, made cosmetic changes to make the code easier to read.
  55.  * 
  56.  * Revision 0.28  92/01/03  15:45:47  drapeau
  57.  * Changed occurrances of "NULL" in calls to Browse() to use "0" instead.
  58.  * This is due to the ANSI definition of NULL as "(void*)0".
  59.  * Also, updated List() function to set currentAudio variable as
  60.  * appropriate for the current edit.
  61.  * 
  62.  * Also made minor cosmetic changes.
  63.  * 
  64.  * Revision 0.27  91/09/24  21:34:55  lim
  65.  * Changed 'vEdit' to 'VideoEdit' everywhere.
  66.  * 
  67.  * Revision 0.26  91/09/04  14:19:20  lim
  68.  * *** empty log message ***
  69.  * 
  70.  * Revision 0.25  91/08/30  15:44:06  lim
  71.  * Header increased to 21 char in length.
  72.  * 
  73.  * Revision 0.24  91/08/23  17:16:29  lim
  74.  * Document format has been changed.
  75.  * 
  76.  * Revision 0.23  91/08/20  15:16:11  lim
  77.  * Fixed deleting of old edits.
  78.  * 
  79.  * Revision 0.22  91/08/17  20:52:45  lim
  80.  * OpenPanel is now Browse.
  81.  * 
  82.  * Revision 0.21  91/08/16  13:10:00  lim
  83.  * 1. Interface changes. Merged editCurrSelMsg into editNewEditMsg.
  84.  * 2. DeleteAll() causes titlebar to change to "untitled document". 
  85.  *    Titlebar now shows filename.
  86.  * 
  87.  * Revision 0.20  91/08/09  17:30:19  lim
  88.  * Included OpenPanel.
  89.  * 
  90.  * Revision 0.19  91/08/08  11:27:09  lim
  91.  * Zero speed is not permitted in the edit list.
  92.  * 
  93.  * Revision 0.18  91/08/07  14:33:44  lim
  94.  * *** empty log message ***
  95.  * 
  96.  * Revision 0.17  91/08/07  14:31:47  lim
  97.  * Update currentAudio in FileLoad().
  98.  * 
  99.  * Revision 0.16  91/08/07  13:27:47  lim
  100.  * 1. ErrorCheck() has been removed. The responsibility for notification of 
  101.  * error has been shifted to the device drivers, which will call DisplayError()
  102.  * in 'videoObjects.c'.
  103.  * 2. Added instance pointer, "theObject" to all public function calls.
  104.  * 
  105.  * Revision 0.15  91/08/02  12:59:45  lim
  106.  * 'currentAudio' is no longer static.
  107.  * 
  108.  * Revision 0.14  91/07/27  22:29:16  lim
  109.  * Speed changed from double to int.
  110.  * 
  111.  * Revision 0.13  91/07/24  11:02:02  lim
  112.  * Whenever editAudioMenu is called, a static variable "currentAudio" is set.
  113.  * In EditAdd/EditModify, the array audioStg is set to currentAudio, instead of
  114.  * the old way in which audioStg is always set when the editAudioMenu is called.
  115.  * 
  116.  * Revision 0.12  91/07/19  16:15:17  lim
  117.  * Added check for editnum != -1 in EditSpeedStg
  118.  * 
  119.  * Revision 0.11  91/07/19  14:11:50  lim
  120.  * Renamed print_onlist and print_numedits according to specs.
  121.  * Changed code to fit in audio and speed setting options for
  122.  * edits.
  123.  * 
  124.  * Revision 0.10  91/07/12  16:19:53  lim
  125.  * Initial revision implementing VideoObject.
  126.  *  */
  127.  
  128. #include "VideoEdit.h"
  129.  
  130. static char editrcs[] = "$Header: /Source/Media/collab/VideoEdit/RCS/VideoEditEdit.c,v 0.31 92/05/13 00:17:32 drapeau Exp Locker: drapeau $";
  131.  
  132. int currentAudio;
  133. char currentFilename[256];                        /* Name of file currently loaded */
  134.  
  135. /*     VIDEO EDIT FUNCTIONS (POPUP WINDOW 2)     */
  136.  
  137. /* format an edit entry for the panel list */
  138. void
  139. PrintOnList(current, buf)
  140.      int current;
  141.      char buf[70];
  142. {
  143.   char audio[7];
  144.   
  145.   switch (currentAudio)
  146.   {
  147.    case Stereo:
  148.     strcpy(audio, "Stereo");
  149.     break;
  150.    case Right:
  151.     strcpy(audio, "Right");
  152.     break;
  153.    case Left:
  154.     strcpy(audio, "Left");
  155.     break;
  156.    case Mute:
  157.     strcpy(audio, "Mute");
  158.     break;
  159.    default:
  160.     DisplayError("Invalid audio setting", " ");
  161.     return;
  162.   }
  163.   
  164.   sprintf (buf, " %5d.  %-26.22s%5d    %5d   %-8s%d", 
  165.        current+1, label[current], startframe[current], endframe[current], 
  166.        audio, speedStg[current]);
  167. }
  168.  
  169. /* print the number of edit entries on the list */
  170. void
  171. PrintNumEdits()
  172. {
  173.   char edit[20];
  174.   
  175.   sprintf(edit, "No. of Edits : %d", lines);
  176.   xv_set(VideoEdit_editPopup->editNumEditMsg, PANEL_LABEL_STRING, 
  177.      edit, NULL);
  178. }
  179.  
  180. /* file error handling procedure */
  181. void 
  182. FileError(optype)
  183.      int optype;
  184. {
  185.   char buf[40];
  186.   
  187.   if (optype == SAVE) 
  188.     strcpy(buf, "Error in writing file.");
  189.   else 
  190.     switch(errno) 
  191.     {
  192.      case ENOTDIR:
  193.      case EFAULT : 
  194.       case ENOENT : strcpy(buf, "File or directory does not exist.");
  195.        break;
  196.       case EACCES : strcpy(buf, "File path search permission denied.");
  197.        break;
  198.        default    : strcpy(buf, "Error in opening file.");
  199.        break;
  200.      }
  201.   
  202.   DisplayError(buf, " ");
  203. }
  204.  
  205. /*
  206.  * Menu handler for `DocMenu (Open)' to load an edit file.
  207.  */
  208. Menu_item
  209. FileLoad(item, op)
  210.     Menu_item    item;
  211.     Menu_generate    op;
  212. {
  213.   int result;
  214.   if (op != MENU_NOTIFY)
  215.     return item;
  216.  
  217.   if ((change) && (lines > 0))                        /* check if unsaved changes exist in edit list */
  218.   {
  219.     result = notice_prompt(VideoEdit_editPopup->editPopup, NULL,
  220.                NOTICE_MESSAGE_STRINGS,
  221.                "Unsaved changes exist in the edit list.",
  222.                "Loading a file will erase all changes.",
  223.                "Go ahead and load the file?",
  224.                NULL,
  225.                NOTICE_BUTTON_NO,    "Yes",
  226.                NOTICE_BUTTON_YES,    "No",
  227.                NULL);
  228.     if (result == NOTICE_YES)
  229.       return;
  230.   }
  231.   
  232.   Browse(NULL, BrowseOpen, 0, "#Video Edit Document#", "VideoEdit");
  233.   return item;
  234.   
  235. }
  236.  
  237. void
  238. DisplayEditList(oldlines, newlines)
  239.      int oldlines;
  240.      int newlines;
  241. {
  242.   int i;
  243.   char    buf[70];
  244.       
  245.   if (editnum != -1)                            /* Deselect any current selection */
  246.     xv_set(VideoEdit_editPopup->editScrollList,
  247.        PANEL_LIST_SELECT, editnum, FALSE,
  248.        NULL);
  249.   for (i=0; (i<oldlines && newlines > 0); i++)                /* Replace the old string by the new one */
  250.   {
  251.     currentAudio = audioStg[i];
  252.     PrintOnList(i, buf);
  253.     xv_set (VideoEdit_editPopup->editScrollList,
  254.         PANEL_LIST_STRING, i, buf,
  255.         PANEL_LIST_FONT, i, font,
  256.         NULL);
  257.   }
  258.   
  259.   if (oldlines < newlines)                        /* Insert the additional new strings */
  260.     for (i=oldlines; i<newlines; i++) 
  261.     {
  262.       currentAudio = audioStg[i];
  263.       PrintOnList(i, buf);
  264.       xv_set (VideoEdit_editPopup->editScrollList,
  265.           PANEL_LIST_INSERT, i,
  266.           PANEL_LIST_STRING, i, buf,
  267.           PANEL_LIST_FONT, i, font,
  268.           NULL);
  269.     }
  270.                                     
  271.   else                                    /* delete all additional old entries in the edit list */
  272.     for (i=oldlines-1; i>newlines-1; i--)
  273.       xv_set(VideoEdit_editPopup->editScrollList,
  274.          PANEL_LIST_DELETE, i,
  275.          NULL);
  276.   
  277.   PrintNumEdits();
  278.   xv_set(VideoEdit_editPopup->editModButton,                /* Set modify, delete buttons to inactive */
  279.      PANEL_INACTIVE, TRUE, NULL);
  280.   xv_set(VideoEdit_editPopup->editDelButton,
  281.      PANEL_INACTIVE, TRUE, NULL);
  282.  
  283.   sprintf(currentFilename, "Untitled");                    /* Housekeeping - clear out currentFilename, ... */
  284.   editnum = -1;                                /* ...editnum and change */
  285.   change = 0;
  286. }
  287.  
  288.  
  289. int 
  290.   OpenHandler(proposedPath, id)
  291. char* proposedPath;
  292. int id;
  293. {
  294.   int    i;
  295.   int    oldlines;
  296.   char    header[22];
  297.   char    tempLabel[32];
  298.   FILE*    fp;
  299.   
  300.   fp = fopen(proposedPath, "r");                    /* Open file read only */
  301.   fgets(header, 22, fp);                        /* check if file is a video edit file */
  302.   if (strcmp(header, "#Video Edit Document#") != 0) 
  303.   {
  304.     DisplayError("Not a video edit file.", " ");
  305.     fclose(fp);
  306.     return 1;
  307.   }
  308.   oldlines = lines;
  309.   fscanf(fp, "%*s%*s%*s%d", &lines);
  310.   for (i=0; i<lines; i++) 
  311.   {
  312.     fscanf(fp, "%*s%*s%*d\n");                       
  313.     fscanf(fp, "%*s%*s%d\n", &startframe[i]);
  314.     fscanf(fp, "%*s%*s%d\n", &endframe[i]);
  315.     fscanf(fp, "%*s%*s%d\n", &audioStg[i]);
  316.     fscanf(fp, "%*s%*s%*s%d\n", &speedStg[i]);
  317.     fgets(tempLabel, 32, fp);
  318.     strncpy(label[i], &tempLabel[8], 22);
  319.     if (strlen(label[i]) < 22)                        /* Remove newline character for label if necessary */
  320.       label[i][strlen(label[i])-1] = '\0';
  321.     if ((strlen(label[i]) == 22) && (label[i][21] == '\n'))
  322.       label[i][21] = '\0';
  323.   }
  324.   fclose (fp);
  325.   
  326.   DisplayEditList(oldlines, lines);                    /* Display these new lines on edit list */
  327.   
  328.   xv_set(VideoEdit_editPopup->editNewEditMsg, 
  329.      PANEL_LABEL_STRING, "Current Selection : New Edit", 
  330.      NULL);
  331.   UpdateHeader(proposedPath, 0);                    /* Print new filename on title bar */
  332.   strcpy(currentFilename, proposedPath);                /* Copy filename into currentFilename */
  333.   return 0;
  334. }                                    /* end function OpenHandler */
  335.  
  336.  
  337.  
  338. /*
  339.  * Menu handler for `DocMenu (Save)' to save an edit file.
  340.  */
  341. Menu_item
  342. FileSave(item, op)
  343.     Menu_item    item;
  344.     Menu_generate    op;
  345. {
  346.   if ((op == MENU_NOTIFY) && lines)
  347.   {
  348.     if (strcmp(currentFilename, "Untitled") != 0)
  349.       Browse(currentFilename, BrowseCheckSave, 1,            /* ID = 1 for checksave */
  350.          "#Video Edit Document#", "VideoEdit");
  351.     else                                /* There is no current file */
  352.       Browse(NULL, BrowseSave, 0, "#Video Edit Document#", "VideoEdit");
  353.   }
  354.   return item;
  355.     
  356. }
  357.  
  358. /*
  359.  * Menu handler for `DocMenu (Save As...)' 
  360.    to save an edit file (Save As... from DocMenu under EditDocButton).
  361.  */
  362. Menu_item
  363. FileSaveAs(item, op)
  364.     Menu_item    item;
  365.     Menu_generate    op;
  366. {
  367.   if ((op == MENU_NOTIFY) && lines)
  368.     Browse(NULL, BrowseSave, 0, "#Video Edit Document#", "VideoEdit");
  369.   return item;
  370.   
  371. }
  372.  
  373.  
  374.  
  375. int
  376.   SaveHandler(char* proposedPath, int id)
  377. {
  378.   struct stat stbuf;
  379.   int i;
  380.   int result;
  381.   char header[22];
  382.   char buf[40];
  383.   FILE* fp;
  384.   
  385.   if (stat(proposedPath, &stbuf) == 0)                    /* Does file exist?  If so, is it a VideoEdit document? */
  386.   {
  387.     fp = fopen(proposedPath, "r");
  388.     fgets(header, 22, fp);
  389.     fclose(fp);
  390.     if (strcmp(header, "#Video Edit Document#") != 0) 
  391.       sprintf(buf, "This file is not a video edit file.");
  392.     else 
  393.       sprintf(buf, "This video edit file exists.");
  394.     if (!id)                                /* Not checksave */
  395.     {
  396.       result = notice_prompt(VideoEdit_editPopup->editPopup, NULL,
  397.                  NOTICE_MESSAGE_STRINGS,
  398.                  buf,
  399.                  "Do you wish to overwrite it?",
  400.                  NULL,
  401.                  NOTICE_BUTTON_NO,    "Yes",
  402.                  NOTICE_BUTTON_YES,    "No",
  403.                  NULL);
  404.       if (result == NOTICE_YES) 
  405.     return 1;
  406.     }
  407.   }
  408.   
  409.   fp = fopen(proposedPath, "w");
  410.   if (fp == NULL)                            /* Check if file was properly opened */
  411.   {
  412.     FileError(SAVE);
  413.     return 1;
  414.   }
  415.   lines = xv_get(VideoEdit_editPopup->editScrollList, 
  416.          PANEL_LIST_NROWS);
  417.   
  418.   fprintf(fp, "#Video Edit Document#\n");                /* Write contents of the edit list to the file */
  419.   fprintf(fp, "#Number of Edits:\t%d\n\n", lines);
  420.   for (i=0; i<lines; i++) 
  421.   {
  422.     fprintf(fp, "#Edit Number:\t%d\n", i+1);
  423.     fprintf(fp, "#Start Address:\t%d\n", startframe[i]);
  424.     fprintf(fp, "#End Address:\t%d\n", endframe[i]);
  425.     fprintf(fp, "#Audio Setting:\t%d\n", audioStg[i]);
  426.     fprintf(fp, "#Speed in frames/second:\t%d\n", speedStg[i]);
  427.     fprintf(fp, "#Label:\t%s\n\n", label[i]);
  428.   }
  429.   fclose (fp);
  430.   if (!id)                                /* Was a SaveAs */
  431.   {
  432.     bzero(currentFilename, 256);
  433.     strcpy(currentFilename, proposedPath);
  434.   }
  435.   change = 0;
  436.   UpdateHeader(proposedPath, 0);
  437.   return 0;
  438. }                                    /* end function SaveHandler */
  439.  
  440.  
  441.  
  442. /*
  443.   To close both the edit and preview popup windows.
  444.   */
  445. void
  446. EditDone(item, event)
  447.      Panel_item    item;
  448.      Event        *event;
  449. {
  450.   xv_set(VideoEdit_previewPopup->previewPopup, FRAME_CMD_PUSHPIN_IN, FALSE, NULL);
  451.   xv_set(VideoEdit_previewPopup->previewPopup, XV_SHOW, FALSE, NULL);
  452.   xv_set(VideoEdit_editPopup->editPopup, FRAME_CMD_PUSHPIN_IN, FALSE, NULL);
  453.   xv_set(VideoEdit_editPopup->editPopup, XV_SHOW, FALSE, NULL);
  454. }
  455.  
  456. /*
  457.  * Menu handler for `DocMenu (Close Window)'.
  458.  */
  459. Menu_item
  460. EditCloseWindow(item, op)
  461.     Menu_item    item;
  462.     Menu_generate    op;
  463.   if (op == MENU_NOTIFY)
  464.   {
  465.     xv_set(VideoEdit_previewPopup->previewPopup, FRAME_CMD_PUSHPIN_IN, FALSE, NULL);
  466.     xv_set(VideoEdit_previewPopup->previewPopup, XV_SHOW, FALSE, NULL);
  467.     xv_set(VideoEdit_editPopup->editPopup, FRAME_CMD_PUSHPIN_IN, FALSE, NULL);
  468.     xv_set(VideoEdit_editPopup->editPopup, XV_SHOW, FALSE, NULL);
  469.   }
  470.   return item;
  471. }
  472.  
  473.  
  474. /*
  475.  * Menu handler for `DocMenu (Close File)'.
  476.  */
  477. Menu_item
  478.   EditCloseFile(item, op)
  479. Menu_item    item;
  480. Menu_generate    op;
  481. {  
  482.   int result;
  483.   
  484.   if (op != MENU_NOTIFY)
  485.     return item;  
  486.   if ((change) && (lines > 0)) 
  487.   {
  488.     result = notice_prompt(VideoEdit_editPopup->editPopup, NULL,
  489.                NOTICE_MESSAGE_STRINGS,
  490.                "Unsaved changes exist in the edit list.",
  491.                "Go ahead and close file without saving changes? ",
  492.                NULL,
  493.                NOTICE_BUTTON_NO,    "Yes",
  494.                NOTICE_BUTTON_YES,    "No",
  495.                NULL);
  496.     if (result == NOTICE_YES)
  497.       return item;
  498.   }            
  499.   
  500.   DisplayEditList(lines, 0);                        /* Display new edit list which originally had 'lines'
  501.                                        and now has 0 lines. */
  502.   lines = 0;
  503.   xv_set(VideoEdit_editPopup->editNewEditMsg, 
  504.      PANEL_LABEL_STRING, "Current Selection : None", 
  505.      NULL);
  506.   UpdateHeader("Untitled", 0);
  507.   xv_set(VideoEdit_editPopup->editStartTxt, 
  508.      PANEL_VALUE, 0, NULL);
  509.   xv_set(VideoEdit_editPopup->editEndTxt, 
  510.      PANEL_VALUE, 0, NULL);
  511.   xv_set(VideoEdit_editPopup->editDurTxt, 
  512.      PANEL_VALUE, "0", NULL);
  513.   xv_set(VideoEdit_editPopup->editLabelTxt, 
  514.      PANEL_VALUE, " ", NULL);
  515.   xv_set(VideoEdit_editPopup->editSpeedTxt, 
  516.      PANEL_VALUE, 30, NULL);
  517.   
  518.   return item;
  519. }
  520.  
  521.  
  522. /*
  523.  * Menu handler for `editAudioMenu (Stereo)'.
  524.  */
  525. Menu_item
  526. EditAudioStereo(item, op)
  527.     Menu_item    item;
  528.     Menu_generate    op;
  529. {
  530.   if (op == MENU_NOTIFY)
  531.   {
  532.     xv_set(VideoEdit_editPopup->editAudioMenuButton, PANEL_LABEL_STRING, "Stereo", NULL);
  533.     currentAudio = Stereo;
  534.   }
  535.   
  536.   return item;
  537.   
  538. }
  539.  
  540.  
  541. /*
  542.  * Menu handler for `editAudioMenu (Right)'.
  543.  */
  544. Menu_item
  545. EditAudioRight(item, op)
  546.     Menu_item    item;
  547.     Menu_generate    op;
  548. {
  549.   
  550.   if (op == MENU_NOTIFY)
  551.   {
  552.     xv_set(VideoEdit_editPopup->editAudioMenuButton, PANEL_LABEL_STRING, "Right", NULL);
  553.     currentAudio = Right;
  554.   }
  555.   
  556.   return item;
  557. }
  558.  
  559.  
  560. /*
  561.  * Menu handler for `editAudioMenu (Left)'.
  562.  */
  563. Menu_item
  564. EditAudioLeft(item, op)
  565.     Menu_item    item;
  566.     Menu_generate    op;
  567. {
  568.   if (op == MENU_NOTIFY)
  569.   {
  570.     xv_set(VideoEdit_editPopup->editAudioMenuButton, PANEL_LABEL_STRING, "Left", NULL);
  571.     currentAudio = Left;
  572.   }
  573.   
  574.   return item;
  575.   
  576. }
  577.  
  578.  
  579. /*
  580.  * Menu handler for `editAudioMenu (Mute)'.
  581.  */
  582. Menu_item
  583. EditAudioMute(item, op)
  584.     Menu_item    item;
  585.     Menu_generate    op;
  586. {
  587.   if (op == MENU_NOTIFY)
  588.   {
  589.     xv_set(VideoEdit_editPopup->editAudioMenuButton, PANEL_LABEL_STRING, "Mute", NULL);
  590.     currentAudio = Mute;
  591.   }
  592.   
  593.   return item;
  594.   
  595. }
  596.  
  597.  
  598. /*
  599.  * Notify callback function for `editSpeedTxt'.
  600.  */
  601. Panel_setting
  602. EditSpeedStg(item, event)
  603.      Panel_item    item;
  604.      Event        *event;
  605. {
  606.   if ((event_action(event) != '\r') && (event_action(event) != '\n'))
  607.     return panel_text_notify(item, event);
  608.  
  609.   if (editnum != -1)
  610.     speedStg[editnum] =  (int) xv_get(item, PANEL_VALUE);
  611.   SetDuration();
  612.   
  613.   return panel_text_notify(item, event);
  614. }
  615.  
  616. /*
  617.   Button notify proc to get the start frame number (editGetStartButton)
  618.   */
  619. void
  620. GetStart(item, event)
  621.      Panel_item    item;
  622.      Event        *event;
  623. {
  624.   int current;
  625.   
  626.   current = DevQueryFrame(myVideo);
  627.   xv_set (VideoEdit_editPopup->editStartTxt, 
  628.       PANEL_VALUE, current, 
  629.       NULL);
  630. }
  631.  
  632. /*
  633.   Button notify proc to get the end frame number (editGetEndButton)
  634.   */
  635. void
  636. GetEnd(item, event)
  637.      Panel_item    item;
  638.      Event        *event;
  639. {
  640.   int current;
  641.   
  642.   current = DevQueryFrame(myVideo);
  643.  
  644.   if (current >= 0)
  645.     xv_set (VideoEdit_editPopup->editEndTxt, 
  646.         PANEL_VALUE, current, 
  647.         NULL);
  648.   SetDuration();
  649. }
  650.  
  651. /*
  652.  * Menu handler for `previewMenu (Play part of edit...)'.
  653.  */
  654. Menu_item
  655. EditPreview(item, op)
  656.      Menu_item       item;
  657.      Menu_generate   op;
  658. {
  659.   switch (op) 
  660.   {
  661.    case MENU_DISPLAY:
  662.     break;
  663.     
  664.    case MENU_DISPLAY_DONE:
  665.     break;
  666.     
  667.    case MENU_NOTIFY:
  668.     xv_set(VideoEdit_previewPopup->previewPopup, 
  669.        FRAME_CMD_PUSHPIN_IN, TRUE, 
  670.        NULL);
  671.     xv_set(VideoEdit_previewPopup->previewPopup, 
  672.        XV_SHOW, TRUE, 
  673.        NULL);
  674.     SetDuration();                            /* get the approximate duration */
  675.     break;
  676.     
  677.    case MENU_NOTIFY_DONE:
  678.     break;
  679.   }
  680.   return item;
  681. }
  682.  
  683.  
  684.  
  685. /*
  686.   Button notify proc to add the current selection to the edit list
  687.   (editAddButton)
  688.   */
  689. void
  690.   EditAdd(item, event)
  691. Panel_item    item;
  692. Event        *event;
  693. {
  694.   char buf[70];
  695.   char s[30];
  696.   
  697.   if ((int) xv_get(VideoEdit_editPopup->editSpeedTxt, PANEL_VALUE) <= 0)
  698.   {
  699.     DisplayError("Zero speed is not acceptable.", "Please enter another value.");
  700.     return;
  701.   }
  702.   
  703.   startframe[lines] = xv_get(VideoEdit_editPopup->editStartTxt,        /* Get start frame, ... */
  704.                  PANEL_VALUE);
  705.   endframe[lines] = xv_get (VideoEdit_editPopup->editEndTxt,        /* ...end frame, label and speed&audio settings */
  706.                 PANEL_VALUE);
  707.   strcpy (label[lines],
  708.       (char*) xv_get (VideoEdit_editPopup->editLabelTxt,
  709.               PANEL_VALUE));
  710.   speedStg[lines] =  (int) xv_get(VideoEdit_editPopup->editSpeedTxt,
  711.                   PANEL_VALUE);
  712.   audioStg[lines] = currentAudio;
  713.   
  714.   PrintOnList(lines, buf);                        /* Add on edit list */
  715.   xv_set(VideoEdit_editPopup->editScrollList,
  716.      PANEL_LIST_INSERT, lines,
  717.      PANEL_LIST_STRING, lines, buf,
  718.      PANEL_LIST_FONT, lines, font,
  719.      NULL);
  720.   if (editnum != -1)
  721.     xv_set(VideoEdit_editPopup->editScrollList,
  722.        PANEL_LIST_SELECT, editnum, FALSE,
  723.        NULL);
  724.   
  725.   xv_set(VideoEdit_editPopup->editScrollList,                /* select the newly added entry */
  726.      PANEL_LIST_SELECT, lines, TRUE,
  727.      NULL);
  728.   editnum = lines;
  729.   lines++;
  730.   change = 1;
  731.   UpdateHeader(currentFilename, 1);
  732.   SetDuration();
  733.   xv_set(VideoEdit_editPopup->editModButton,                /* Make the modify and delete buttons active */
  734.      PANEL_INACTIVE, FALSE, NULL);
  735.   xv_set(VideoEdit_editPopup->editDelButton,
  736.      PANEL_INACTIVE, FALSE, NULL);
  737.   sprintf(s, "Current Selection : Edit #%d", lines);            /* Update edit status info */
  738.   xv_set(VideoEdit_editPopup->editNewEditMsg, PANEL_LABEL_STRING, s, NULL);
  739.   PrintNumEdits();
  740.   change = 1;
  741. }                                    /* end function EditAdd */
  742.  
  743.  
  744.  
  745. /*
  746.   Button notify proc to delete the current selection from the edit list
  747.   (editDelButton)
  748.   */
  749. void
  750.   EditDelete(item, event)
  751. Panel_item      item;
  752. Event           *event;
  753. {
  754.   int i;
  755.   char buf[70];
  756.   
  757.   xv_set(VideoEdit_editPopup->editScrollList,                /* Delete the current selection */
  758.      PANEL_LIST_SELECT, editnum, FALSE,
  759.      NULL);
  760.   if (editnum != 0) 
  761.     xv_set(VideoEdit_editPopup->editScrollList,
  762.        PANEL_LIST_SELECT, editnum - 1, TRUE,
  763.        NULL);
  764.   xv_set(VideoEdit_editPopup->editScrollList,
  765.      PANEL_LIST_DELETE, editnum,
  766.      NULL);
  767.   
  768.   lines --;                                /* Shift all the following edit entries up by one */
  769.   for (i=editnum; i < lines;i++) 
  770.   {
  771.     startframe[i] = startframe[i+1];
  772.     endframe[i] = endframe[i+1];
  773.     strcpy(label[i], label[i+1]);
  774.     audioStg[i] = audioStg[i+1];
  775.     speedStg[i] = speedStg[i+1];
  776.     currentAudio = audioStg[i];
  777.     PrintOnList(i, buf);
  778.     xv_set(VideoEdit_editPopup->editScrollList,
  779.        PANEL_LIST_STRING, i, buf,
  780.        PANEL_LIST_FONT, i, font,
  781.        NULL);
  782.   }
  783.   if (editnum != 0) 
  784.     xv_set(VideoEdit_editPopup->editScrollList,
  785.        PANEL_LIST_SELECT, editnum - 1, FALSE,
  786.        NULL);
  787.   xv_set(VideoEdit_editPopup->editNewEditMsg, 
  788.      PANEL_LABEL_STRING, "Current Selection : New Edit", 
  789.      NULL);
  790.   xv_set(VideoEdit_editPopup->editModButton,                /* Make the delete, modify buttons inactive */
  791.      PANEL_INACTIVE, TRUE, NULL);
  792.   xv_set(VideoEdit_editPopup->editDelButton,
  793.      PANEL_INACTIVE, TRUE, NULL);
  794.   PrintNumEdits();
  795.   change = 1;
  796.   editnum = -1;
  797.   UpdateHeader(currentFilename, 1);
  798. }                                    /* end function EditDelete */
  799.  
  800. /*
  801.   Button notify proc to modify the current selection (editModButton)
  802.   */
  803. void
  804. EditModify(item, event)
  805.      Panel_item    item;
  806.      Event        *event;
  807. {
  808.   char buf[70];
  809.   
  810.   if ((int) xv_get(VideoEdit_editPopup->editSpeedTxt, PANEL_VALUE) <= 0)
  811.   {
  812.     DisplayError("Zero speed not acceptable", "Please enter another value");
  813.     return;
  814.   }
  815.   
  816.   startframe[editnum] = xv_get (VideoEdit_editPopup->editStartTxt, PANEL_VALUE);
  817.   endframe[editnum] = xv_get (VideoEdit_editPopup->editEndTxt, PANEL_VALUE);
  818.   strcpy (label[editnum], (char*) xv_get(VideoEdit_editPopup->editLabelTxt,
  819.                       PANEL_VALUE));
  820.   speedStg[editnum] =  (int) xv_get(VideoEdit_editPopup->editSpeedTxt, PANEL_VALUE);
  821.   audioStg[editnum] = currentAudio;
  822.   
  823.   PrintOnList(editnum, buf);
  824.   xv_set(VideoEdit_editPopup->editScrollList,
  825.      PANEL_LIST_STRING, editnum, buf,
  826.      PANEL_LIST_FONT, editnum, font,
  827.      NULL);
  828.   SetDuration();
  829.   change = 1;
  830.   UpdateHeader(currentFilename, 1);
  831. }                                    /* end function EditModify */
  832.  
  833.  
  834. /*
  835.  * Notify callback function for `editScrollList'.
  836.  */
  837. int
  838.   List(item, string, client_data, op, event)
  839. Panel_item    item;
  840. char        *string;
  841. Xv_opaque    client_data;
  842. Panel_list_op    op;
  843. Event        *event;
  844. {
  845.   int selection;
  846.   char s[30];
  847.   char audio[7];
  848.   
  849.   switch(op) 
  850.   {
  851.    case PANEL_LIST_OP_DESELECT:
  852.     xv_set(VideoEdit_editPopup->editNewEditMsg, PANEL_LABEL_STRING, 
  853.        "Current Selection : New Edit", NULL);
  854.     xv_set(VideoEdit_editPopup->editModButton, PANEL_INACTIVE, TRUE, NULL); /* Make the modify, delete buttons inactive */
  855.     xv_set(VideoEdit_editPopup->editDelButton, PANEL_INACTIVE, TRUE, NULL);
  856.     break;
  857.     
  858.    case PANEL_LIST_OP_SELECT:
  859.     sscanf(string, "%d", &selection);
  860.     editnum = selection - 1;
  861.     sprintf(s, "Current Selection : Edit #%d", selection);
  862.     xv_set(VideoEdit_editPopup->editNewEditMsg, PANEL_LABEL_STRING, s, NULL); /* Load appropriate values into the textfields */
  863.     xv_set(VideoEdit_editPopup->editStartTxt, PANEL_VALUE, startframe[editnum], 
  864.        NULL);
  865.     xv_set(VideoEdit_editPopup->editEndTxt, PANEL_VALUE, endframe[editnum], 
  866.        NULL);
  867.     xv_set(VideoEdit_editPopup->editLabelTxt, PANEL_VALUE, label[editnum], NULL);
  868.     switch (audioStg[editnum])
  869.     {
  870.      case Stereo:
  871.       strcpy(audio, "Stereo");
  872.       currentAudio = Stereo;
  873.       break;
  874.      case Right:
  875.       strcpy(audio, "Right");
  876.       currentAudio = Right;
  877.       break;
  878.      case Left:
  879.       strcpy(audio, "Left");
  880.       currentAudio = Left;
  881.       break;
  882.      case Mute:
  883.       strcpy(audio, "Mute");
  884.       currentAudio = Mute;
  885.       break;
  886.     }
  887.     xv_set(VideoEdit_editPopup->editAudioMenuButton, PANEL_LABEL_STRING, audio, NULL);
  888.     xv_set(VideoEdit_editPopup->editSpeedTxt, PANEL_VALUE, (int) speedStg[editnum], NULL);
  889.     SetDuration();
  890.     xv_set(VideoEdit_editPopup->editModButton,                /* Make the modify, delete buttons active */
  891.        PANEL_INACTIVE, FALSE, NULL);
  892.     xv_set(VideoEdit_editPopup->editDelButton,
  893.        PANEL_INACTIVE, FALSE, NULL);
  894.     break;
  895.   }
  896.   return XV_OK;
  897. }                                    /* end function List */
  898.  
  899.  
  900. /*
  901.  * Notify callback function for `editDelAllButton'.
  902.  * Delete all entries in the edit list
  903.  */
  904. void
  905.   EditDeleteAll(item, event)
  906. Panel_item      item;
  907. Event           *event;
  908. {
  909.   int i;
  910.   int result;
  911.   char edit[20];
  912.  
  913.   if ((change) && (lines > 0))                        /* Check if unsaved changes exist in edit list */
  914.   {
  915.     result = notice_prompt(VideoEdit_editPopup->editPopup, NULL,
  916.                NOTICE_MESSAGE_STRINGS,
  917.                "Unsaved changes exist in the edit list.",
  918.                "Go ahead and delete all entries in the edit list? ",
  919.                NULL,
  920.                NOTICE_BUTTON_NO,    "Yes",
  921.                NOTICE_BUTTON_YES,    "No",
  922.                NULL);
  923.     if (result == NOTICE_YES)
  924.       return;
  925.   }
  926.   for (i=0; i < lines; i++) 
  927.     xv_set(VideoEdit_editPopup->editScrollList,
  928.        PANEL_LIST_DELETE, 0,
  929.        NULL);
  930.   lines  = 0;
  931.   editnum = -1;
  932.   PrintNumEdits();
  933.   sprintf(edit, "No. of Edits : 0");
  934.   
  935.   xv_set(VideoEdit_editPopup->editNumEditMsg, PANEL_LABEL_STRING, 
  936.      edit, NULL);
  937.   xv_set(VideoEdit_editPopup->editNewEditMsg, PANEL_LABEL_STRING, "Current Selection : New Edit", NULL);
  938.   xv_set(VideoEdit_editPopup->editModButton, PANEL_INACTIVE, TRUE, NULL);
  939.   xv_set(VideoEdit_editPopup->editDelButton, PANEL_INACTIVE, TRUE, NULL);
  940.   sprintf(currentFilename, "Untitled");
  941.   change = 0;
  942.   UpdateHeader(currentFilename, 0);
  943. }                                    /* end function EditDeleteAll */
  944.  
  945.  
  946. void UpdateHeader (char* documentName, int modified)
  947. {
  948.   char    label[MAXPATHLEN+32];
  949.   
  950.   if (modified == 1)
  951.   {
  952.     sprintf(label, "%s (modified)",
  953.         documentName);
  954.   }
  955.   else
  956.   {
  957.     sprintf(label, "%s", documentName);
  958.   }
  959.   xv_set(VideoEdit_editPopup->editPopup,                /* Print the new label string on the title bar */
  960.      XV_LABEL, label, NULL);
  961. }                                    /* end function UpdateHeader */
  962.